<?php
class Usersysgroup_ctl extends Ctl{
    function __construct(){
    }
    function main(array $xxfget) {
        $this::sessver();
        $type=!empty($_POST['type'])?$_POST['type']:false;
        $type=!empty($xxfget['type'])?$xxfget['type']:$type;
        if(!$type){
        	$result=xdb::getInstance()->getarray("select * from groupx where type like 'system'");
        	$this::show('usersysgroup',compact('result'));
        }elseif($type=="detail"){
            $id=$xxfget['id'];
            $gname=xdb::getInstance()->getvar("select gname from groupx where id=".$id);
            $result=xdb::getInstance()->getarray("select * from user ");
            $guser=xdb::getInstance()->getarray("select ug.id as ugid,username,realname,mphone,zhiwu,beizhu from user as u,user_groupx as ug where u.id=ug.uid and ug.gid=$id");
            $this::show('usersysgroup_detail',compact('result','id','gname','guser'));
        }elseif ($type=="add"){
        	$array=array();
        	$array2=array();
        	$gname=$_POST['gname'];
        	$uid=XXF_UID;
        	$array['uid']=$uid;
        	$array['gname']=$gname;
        	$array['type']='system';
        	$array2['gname']=$gname;
        	$array2['type']='system';
        	echo xdb::getInstance()->indb('groupx', $array, $array2);
        }elseif ($type=="adduser"){
            $array=array();
            $array2=array();
            $uid=$_POST['uid'];
            $gid=$_POST['gid'];
            $array['uid']=$uid;
            $array['gid']=$gid;
            $array2['uid']=$uid;
            $array2['gid']=$gid;
            echo xdb::getInstance()->indb('user_groupx', $array, $array2);
        }
    }
}